package com.silverhaze.diamond.client.ui.table.renderers;

import com.silverhaze.diamond.client.ui.table.model.CustomersTableModel;

import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import java.awt.*;

/**
 * Created by IntelliJ IDEA.
 * SystemUser: Ivan
 * Date: 20.07.2008
 * Time: 3:16:20
 * To change this template use File | Settings | File Templates.
 */
public class CustomerTableRenderer extends DefaultTableCellRenderer {
    // implements javax.swing.table.TableCellRenderer
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        JComponent rendererComponent = (JComponent) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);

        if (rendererComponent instanceof JLabel) {
            JLabel label = (JLabel) rendererComponent;

            label.setText(" " + value.toString());

            if (column == CustomersTableModel.ID) {
                label.setHorizontalAlignment(SwingConstants.CENTER);
            } else {
                label.setHorizontalAlignment(SwingConstants.LEFT);
            }
        }

        return rendererComponent;    //To change body of overridden methods use File | Settings | File Templates.
    }
}

